function getPageLinks(currentPage,totalPage){
	var pages=[];
	var deautLen=totalPage>5?5:totalPage;
	var start=currentPage-Math.round(deautLen/2);
	start=start<=0?1:start;
	var end=start+deautLen-1;
	end=end>totalPage?totalPage:end;
	for(var i=start;i<=end;i++){
		pages[pages.length]=i;
	}
	return pages;
}

var pagination={
	init:function($scope){
		$scope.next = function () {
	        if ($scope.pageInfo.pageNum < $scope.pageInfo.pages) {
	            $scope.pageInfo.pageNum++;
	            $scope.load(false);
	        }
	    };
	 
	    $scope.prev = function () {
	        if ($scope.pageInfo.pageNum > 1) {
	            $scope.pageInfo.pageNum--;
	            $scope.load(false);
	        }
	    };
	 
	    $scope.loadPage = function (page) {
	        $scope.pageInfo.pageNum = page;
	        $scope.load(false);
	    };
	    
	    $scope.goPage=function(event){//48~57
	    	var goPageNum=$scope.goPageNum;
	    	var keyCode=event.keyCode;
	    	if(keyCode == "13"){
	    		if(!isNaN(goPageNum)){
	    			var gpn=parseInt(goPageNum);
	    			if(gpn>0&&gpn<=$scope.pageInfo.pages){
	    				$scope.pageInfo.pageNum = gpn;
		    	        $scope.load(false);
	    			}
	    		}
	    	}else if(keyCode<48||keyCode>57){
	    		$scope.goPageNum=goPageNum.length>0?goPageNum.substring(0,goPageNum.length-1):"";
	    	}else if(goPageNum==0){
	    		$scope.goPageNum="";
	    	}else if(goPageNum>$scope.pageInfo.pages){
	    		$scope.goPageNum="";
	    	}
	    }
		return $scope;
	}
} 